#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 1e6+10;
int num[maxn];
int kd[11];
int ansb[maxn];
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n;
		memset(kd,0,sizeof(kd));
		scanf("%d",&n);
		int flag = 0;
		for(int i = 0;i<n;i++)
		{
			scanf("%d",&num[i]);
			kd[num[i]]++;
		}
		long long ansa = 0;
		ansb[0] = 0;
		for(int i = 1;i<=9;i++)
		{
			if(kd[i])
			{
				ansa = i;
				kd[i]--;
				break;
			}
		}
		int cnt = 1;
		for(int i = 1;i<=9;i++)
		{
			if(kd[i])
			{
				ansb[1] = i;
				kd[i]--;
				break;
			}
		}
		
		for(int i = 0;i<=9;i++)
		{
			for(int j = 0;j<kd[i];j++)
			{
				ansb[++cnt] = i;
			}
		}
	//	for(int i = 0;i<=cnt;i++) printf("%d",ansb[i]);
	//	printf("****%d\n",ansa);
		int pur = 0;
		for(int i = cnt;i>=0;i--)
		{
			int t = ansb[i]*ansa;
			t = t+pur;
			if(t<10) 
			{
				ansb[i] = t;
				pur = 0;
			}
			else 
			{
				pur = t/10;
				ansb[i] = t%10;
			}
		}
		if(ansb[0]!=0) printf("%d",ansb[0]);
		for(int i = 1;i<=cnt;i++)
		{
			printf("%d",ansb[i]);
		}
		printf("\n");
	}
} 
